<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>规格值管理</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../../include/commonFile.jsp" %>
</head>
<body>
<!--头部-->
<%@include file="../../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/mall/spec/specValueList.do?specId=${mallSpec.id}" id="myForm"
                  method="post">
                <input type="hidden" name="pageNo" id="pageNo" value="${page.page}"/>
            </form>
            <div class="list-content">
                <div class="cl">
                    <table class="layui-table">
                        <colgroup>
                            <col>
                            <col>
                            <col>
                        </colgroup>
                        <thead>
                        <tr>
                            <th>名称</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="specValue" items="${specValues}">
                            <tr>
                                <td>
                                    <div class="ellipsis-1" title="${specValue.value}">${specValue.value}</div>
                                </td>
                                <td>
                                    <div><fmt:formatDate value="${specValue.createDate}" pattern="yyyy-MM-dd HH:mm"/></div>
                                </td>
                                <td class="tb-opts">
                                    <div class="comm-opts">
                                        <a class="green" href="javascript:addSpecValue('${specValue.id}')"
                                           target="_self">
                                            <i class="iconfont icon-edit btn-icon"></i> 编辑
                                        </a>
                                        <a class="red"
                                           href="javascript:txz.deleteObject('确定要删除该规格值？','${ctx}/mall/spec/specValueDelete.do?specValueId=${specValue.id}','规格值已经分配，不能删除')">
                                            <i class="iconfont icon-delete btn-icon"></i> 删除
                                        </a>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
            <div id="page_content" class="page-container"></div>
        </div><!--底部-->
        <%@include file="../../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });
    })
</script>
<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '规格管理'
        }, {
            name: '${mallSpec.name}'
        }, {
            name: '规格值管理'
        }],
        info: '<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>',
        btns: [{
            name: '新增规格值',
            icon: 'add',
            href: 'javascript:addSpecValue(\'\')'
        }, {
            name : '返回',
            icon: 'back',
            href: '${ctx}/mall/spec/list.do'
        }]
    });

    function addSpecValue(specValueId) {
        openDialog("${empty specValueId ? '添加' : '编辑'}规格值", "${ctx}/mall/spec/specValueForm.do?specId=${mallSpec.id}&id=" + specValueId, "455px", "250px")
    }

    function openDialog(title, url, width, height, cb, target) {
        layer.open({
            type: 2,
            area: [width, height],
            title: title,
            maxmin: true, //开启最大化最小化按钮
            content: url,
            btn: ['确定', '关闭'],
            yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                var inputForm = body.find('#inputForm');
                var top_iframe;
                if (target) {
                    top_iframe = target;//如果指定了iframe，则在改frame中跳转
                } else {
                    top_iframe = '_parent';//获取当前active的tab的iframe
                }
                inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                if (iframeWin.contentWindow.doSubmit()) {
                    setTimeout(function () {
                        top.layer.close(index);
                    }, 100);//延时0.1秒，对应360 7.1版本bug

                    setTimeout(function () {
                        window.location.reload();
                    }, 200);
                }

            },
            cancel: function (index) {
            }
        });
    }
</script>
</body>
</html>